package com.example.toutiao.ui.main.frg

import android.view.View
import androidx.fragment.app.Fragment

import com.example.toutiao.R
import com.example.toutiao.base.BaseFragment
import com.example.toutiao.ui.main.adpater.MainTabAdapter
import com.example.toutiao.ui.main.presenter.MinVideoPresenter
import com.example.toutiao.ui.main.view.MinVideoView
import kotlinx.android.synthetic.main.fragment_minvideo.view.*

class MinVideoFragment : BaseFragment<MinVideoView, MinVideoPresenter>(), MinVideoView {
    private var titles: Array<String> = arrayOf<String>()
    private var fragments: MutableList<Fragment> = mutableListOf<Fragment>()
    private var minVideoAdapter: MainTabAdapter? = null
    override fun getLayoutId(): Int = R.layout.fragment_minvideo

    override fun initView(view: View) {

        titles = resources.getStringArray(R.array.minVideo)
        for (i: Int in titles.indices) {
            fragments.add(MinVideoListFragment())
        }
        if (minVideoAdapter == null) {
            minVideoAdapter = MainTabAdapter(childFragmentManager, fragments, titles)
        } else {
            minVideoAdapter!!.notifyDataSetChanged()
        }
        view.vp_min_video.offscreenPageLimit = fragments.size
        view.vp_min_video.adapter = minVideoAdapter
        view.stl_tab_title.setViewPager(view.vp_min_video)
    }

    override fun initData() {

    }

    override fun createPresenter(): MinVideoPresenter = MinVideoPresenter()

    override fun isRegister(): Boolean = false


    override fun <T> setData(data: T) {

    }

    override fun setError(err: String) {
    }

}